
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class Detail extends StatelessWidget {

  final message;
  final key;
  Detail(this.message,{ this.key }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: (){
        _backToHome(context);
        //false 自行写返回路由代码 true flutter 帮助返回
        return Future.value(false);
      },
      child: Scaffold(
        appBar: AppBar(
          title: Text("详情页"),
          // 头部返回按钮
          // leading: ElevatedButton(
          //   onPressed: () => _backToHome(context),
          //   child: Icon(Icons.arrow_back),
          // ),
          centerTitle: true,
        ),
        body: Center(child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(message),
            ElevatedButton(onPressed: () => _backToHome(context), child: Text("回到首页"))
          ],
        )),
      ),
    );
  }
  _backToHome(BuildContext context) {
    Navigator.of(context).pop("a detail message");
  }
}
